/*
 * checkout.java
 *
 * Created on March 26, 2007, 7:11 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package edu.byu.isys413.actions;

import java.util.Random;
import javax.servlet.http.*;
import edu.byu.isys413.group1E.data.*;
import edu.byu.isys413.group1E.handlers.*;

/**This action takes the user back from teh checkout screen, and allows them to continue shopping in whatever track they were in
 *
 * @author Kendall Frazier
 */
public class revieworder implements edu.byu.isys413.web.Action {
    
    /**
     * Creates a new instance of checkout
     */
    public revieworder() {
    }
  
    /** 
     *Processes this method is called when a user wished to review thier order.  It will check the transaction to see which type it
     *is, and will return the user to appropriate page to edit their order.
     *
     *@param HttpServletRequest
     *@param HttpServletResponse
     *
     *@return String the name of the jsp to call
     */
    public String process(HttpServletRequest request, HttpServletResponse response) throws Exception {
        HttpSession session = request.getSession();
        PrintHandler pHandler = new PrintHandler();
        SaleHandler sHandler = SaleHandler.getInstance();
        TransactionDAO TXDAO = TransactionDAO.getInstance();
        TransLineDAO TLDAO = TransLineDAO.getInstance();
        
        String txguid = request.getParameter("txguid");
        String rstype = TXDAO.read(txguid).getTxLineList().get(0).getRevSrc().getType();
        loadCatalog2 catLoader = new loadCatalog2();
        loadRentals2 rentLoader = new loadRentals2();
        String returnstring = "";
        printhome2 ph = new printhome2();
        
        
        if (rstype.equals("sale"))
        {
            returnstring = catLoader.process(request, response);
        }
        if (rstype.equals("rental"))
        {
            returnstring = rentLoader.process(request, response);
        }
        if (rstype.equals("print"))
        {
             returnstring = ph.process(request, response);
        }
        if (rstype.equals("backup"))
        {
            returnstring = "orderspace.jsp";
        }
        
   return returnstring;
        
    }//process
    
    
}//checkout class
